<?php

namespace App\Console\Commands;

use App\Service\PointsService;
use App\Service\TouchService;
use Illuminate\Console\Command;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Log;

class ClearTouchBonus extends Command
{
    /**
     * The name and signature of the console command.
     *
     * @var string
     */
    protected $signature = 'command:clear_touch_bonus';

    /**
     * The console command description.
     *
     * @var string
     */
    protected $description = '结算昨日量碰奖金';

    /**
     * Create a new command instance.
     *
     * @return void
     */
    public function __construct()
    {
        parent::__construct();
    }

    /**
     * Execute the console command.
     *
     * @return mixed
     */
    public function handle()
    {
        Log::info('量碰定时任务开始执行');
        (new PointsService())->AmountTouch();
        Log::info('量碰定时任务执行完毕');
//        $canTouch = DB::table('btrees')->where('lchild', '<>', 0)->where('rchild', '<>', 0)->pluck('uid');
//        $touchService = new TouchService();
//        Log::info('量碰定时脚本开始执行');
//        foreach ($canTouch as $uid) {
//            $re = $touchService->clearYesTouchBonus($uid);
//            if ($re) {
//                sleep(1);
//            }
//        }
//        Log::info('量碰定时脚本执行完毕');
    }
}
